home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWResour / Include / FWPrvRAc.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  4.7 KB  |  176 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:        FWPrvRAc.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWPRVRAC_H
  11. #define FWPRVRAC_H
  12.  
  13. #ifndef FWSTDDEF_H
  14. #include "FWStdDef.h"
  15. #endif
  16.  
  17. #ifndef FWFILESP_H
  18. #include "FWFileSp.h"
  19. #endif
  20.  
  21. #ifndef FWRESFI_K
  22. #include "FWResFil.k"
  23. #endif
  24.  
  25. #ifndef FWRESFI_H
  26. #include "FWResFil.h"
  27. #endif
  28.  
  29. #ifndef  FWCOUPTR_H
  30. #include "FWCouPtr.h"
  31. #endif
  32.  
  33. #if defined(FW_BUILD_WIN) && !defined(__WINDOWS_H)
  34. #include <windows.h>
  35. #endif
  36.  
  37. #if defined(FW_BUILD_MAC) && !defined(__TYPES__)
  38. #include <Types.h>
  39. #endif
  40.  
  41. #if FW_LIB_EXPORT_PRAGMAS
  42. #pragma lib_export on
  43. #endif
  44.  
  45. //========================================================================================
  46. // CLASS FW_CPrivResourceRep
  47. //
  48. // This internal class is the reference counted representation class used by the
  49. // FW_CResource class defined above.
  50. //========================================================================================
  51.  
  52. class FW_CLASS_ATTR FW_CPrivResourceRep : public FW_CCountedPtrRep
  53. {
  54. public:
  55.     virtual ~ FW_CPrivResourceRep();
  56.         // Releases the resource handle
  57.     
  58.     FW_CPrivResourceRep(const FW_CResourceFile &file,
  59.                         FW_ResourceId resourceId,
  60.                         FW_ResourceType resourceType);
  61.         // Acquires the resource handle
  62.                  
  63.     unsigned long GetSize() const;
  64.         // Return the size of this resource in bytes.
  65.                            
  66.     void* GetData();
  67.         // Lock the resource and return a pointer to the data.
  68.         // Client assumes responsiblity to call ReleaseData.
  69.         
  70.     void ReleaseData();
  71.         // Unlock the resource.
  72.  
  73.     FW_ResourceHandle GetResourceHandle() const;
  74.         // Return the platform (native) handle.
  75.         // This method should be used with caution, since it reveals platform specifics,
  76.         // and allows violation of internal lock counts, etc.
  77.  
  78. private:
  79.  
  80.     FW_CResourceFile    fResourceFile;
  81.         // The resources file this resource originated from.
  82.         
  83.     FW_ResourceId        fResourceID;
  84.         // The resource ID of the resource.
  85.         
  86.     FW_ResourceType        fResourceType;
  87.         // The type of the resource.
  88.  
  89.     FW_ResourceHandle    fResourceHandle;
  90.         // The native resource handle.
  91.         
  92.     unsigned long fResourceSize;
  93.         // The size of the resource, in bytes.
  94.  
  95.     unsigned long GetResourceSize(FW_ResourceHandle handle);
  96.         // Return the size of the resource in bytes.
  97.         
  98. #ifdef FW_BUILD_MAC
  99.     unsigned short fLockCount;
  100.         // Incremented for every GetData, decremented for every ReleaseData
  101.  
  102.     FW_PlatformHandle fResourceData;
  103.         // Resource data is stored here.
  104. #endif
  105.  
  106. #ifdef FW_BUILD_WIN
  107.     HGLOBAL        fLoadedHandle;
  108. #endif
  109.  
  110. private:
  111.  
  112.     FW_CPrivResourceRep(const FW_CPrivResourceRep&);
  113.         // Don't allow copy construction
  114.         
  115.     FW_CPrivResourceRep& operator=(const FW_CPrivResourceRep&);
  116.         // Don't allow copy by value
  117.                  
  118. };
  119.  
  120. //----------------------------------------------------------------------------------------
  121. // FW_CPrivResourceRep::GetSize
  122. //----------------------------------------------------------------------------------------
  123.  
  124. inline unsigned long FW_CPrivResourceRep::GetSize() const
  125. {
  126.     return fResourceSize;
  127. }
  128.  
  129. //----------------------------------------------------------------------------------------
  130. // FW_CPrivResourceRep::GetResourceHandle
  131. //----------------------------------------------------------------------------------------
  132.  
  133. inline FW_ResourceHandle FW_CPrivResourceRep::GetResourceHandle() const
  134. {
  135.     return fResourceHandle;
  136. }
  137.  
  138. //========================================================================================
  139. // CLASS FW_PPrivResourceAccess
  140. //========================================================================================
  141.  
  142. class FW_CLASS_ATTR FW_PPrivResourceAccess : public FW_CCountedPtr
  143. {
  144. public:
  145.     FW_PPrivResourceAccess(FW_CPrivResourceRep* privResourceAccessRep);
  146.     virtual ~ FW_PPrivResourceAccess();
  147.         
  148.     // ----- Overload of accessors methods -----
  149.     FW_CPrivResourceRep* operator->() const;
  150.     FW_CPrivResourceRep& operator*() const;    
  151. };
  152.         
  153. //----------------------------------------------------------------------------------------
  154. // FW_PPrivResourceAccess::operator->
  155. //----------------------------------------------------------------------------------------
  156.  
  157. inline FW_CPrivResourceRep* FW_PPrivResourceAccess::operator->() const
  158. {
  159.     return (FW_CPrivResourceRep*)fRep;
  160. }
  161.  
  162. //----------------------------------------------------------------------------------------
  163. // FW_PPrivResourceAccess::operator*
  164. //----------------------------------------------------------------------------------------
  165.  
  166. inline FW_CPrivResourceRep& FW_PPrivResourceAccess::operator*() const
  167. {
  168.     return *((FW_CPrivResourceRep*)fRep);
  169. }
  170.  
  171. #if FW_LIB_EXPORT_PRAGMAS
  172. #pragma lib_export off
  173. #endif
  174.  
  175. #endif
  176.